
from rest_framework import serializers
from .models import *
from ctbloge.apps.cms.models import Category

class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category
        fields = ['id','name']

class ResourceSerializer(serializers.ModelSerializer):
    author = serializers.CharField(source='author.nickname', read_only=True)
    category = CategorySerializer(read_only=True)

    class Meta:
        model = Resource
        fields = '__all__'

class FavSiteSerializer(serializers.ModelSerializer):
    category = CategorySerializer(read_only=True)
    class Meta:
        model = FavSite
        fields = '__all__'
class ToolSerializer(serializers.ModelSerializer):
    category = CategorySerializer(read_only=True)
    class Meta:
        model = Tool
        fields = '__all__'


